package com.awan.utils.android.image;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.util.Log;

public class Utils {
	public static boolean finishUpdate=false;
    public static void CopyStream(InputStream is, OutputStream os)
    {
        final int buffer_size=2048;
        try
        {
            byte[] bytes=new byte[buffer_size];
            for(;;)
            {
              int count=is.read(bytes, 0, buffer_size);
              if(count==-1){
            	  break;
              }
                  
              os.write(bytes, 0, count);
            }
            finishUpdate=true;
            //if sukses kirim notifikasi
            
            
        }
        catch(Exception ex){
        	Log.e("copy stream","copy stream gagal ==>>"+ex);
        	try {
        		is.close();
				os.close();
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Log.e("copy stream","closing os /is gagal ==>>"+e);
			}
        }
    }
}